package me.zhengjie.modules.detailed_subject.controller;

import me.zhengjie.modules.detailed_subject.Entity.Subject;
import me.zhengjie.modules.detailed_subject.Entity.SubjectDto;
import me.zhengjie.modules.detailed_subject.Entity.SubjectVo;
import me.zhengjie.modules.detailed_subject.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
@CrossOrigin
public class SubjectController {

    @Autowired
    private SubjectService subjectService;
    //获取分类
    @GetMapping("getSubject")
    public List<SubjectDto> getsubject(){
        List<SubjectDto> list =subjectService.getSubject();
        return list;
    }

    //新增分类
    @PostMapping("addsubject")
    public void addsubject(@RequestBody SubjectVo subjectVo){
        subjectService.addsubject(subjectVo);
    }
    //删除分类
    @DeleteMapping("removesubject/{id}")
    public void remocesubject(@PathVariable String id){
        subjectService.remocesubject(id);
    }
}
